<?php
/*
 * Copyright 2010 Clavid AG
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

require_once('ClavidOAuth.php');

/**
 * This class provides SuisseID specific OAUTH handling.
 * 
 * @version $Id: ClavidOAuthSuisseID.php 6 2010-05-17 09:19:49Z telbie $
 */
class ClavidOAuthSuisseID extends ClavidOAuth {

  const Clavid_Error    = 'clavid_error';
  const SuisseID_Number = 'suisseid_number';
  const SuisseID_Name   = 'suisseid_name';
  const SuisseID_EMail  = 'suisseid_email';
  
  private $suisseid_attributes = array();

  private $user_language = 'en';

  public function setUserLanguage($language) {
    $this->user_language = $language;
  }
  
  public function setRequiredAttribute($attributeName) {
    $this->suisseid_attributes[$attributeName] = 'required';
  }
  
  public function setOptionalAttribute($attributeName) {
    $this->suisseid_attributes[$attributeName] = 'optional';
  }

  function getRequestTokenParameters() {
    $parameters = parent::getRequestTokenParameters();
    $parameters['clavid_service'] = 'suisseid';
    $parameters['user_language'] = $this->user_language;

    $it = new ArrayIterator(&$this->suisseid_attributes);
    foreach ($it as $key=>$value) {
      $parameters[$key] = $value;
    }

    return $parameters;
  }

}


?>